/*
** lib.c for  in /home/gomes_m//svn/tek2/zappy-2016-gomes_m/reseau/server
** 
** Made by mickael gomes
** Login   <gomes_m@epitech.net>
** 
** Started on  Tue Jun 25 18:17:46 2013 mickael gomes
** Last update Fri Jul 26 13:31:37 2013 mickael gomes
*/

#include		<unistd.h>
#include		<stdlib.h>
#include		"struct.h"
#include		"prototypes.h"

void			my_putstr(int fd, char *str, int ex)
{
  if (write(fd, str, my_strlen(str)) == -1)
    exit(EXIT_FAILURE);
  if (ex == 1)
    exit(EXIT_FAILURE);
}

int			my_strlen(char *str)
{
  int			i = 0;

  while (str[i])
    i++;
  return (i);
}

int			my_strcmp(char *str1, char *str2)
{
  if (str1 == NULL || str2 == NULL)
    return (1);
  if (my_strlen(str1) != my_strlen(str2))
    return (1);
  while (*str1 && *str2)
    {
      if (*(str1++) != *(str2++))
	return (1);
    }
  return (0);
}

t_list			*my_put_in_list(t_list *list)
{
  t_list		*element;

  element = xmalloc(sizeof(*element));
  init_list(element, list->cmd->env);
  list->next = element;
  return (list);
}

int			my_strncmp(char *str1, char *str2, int len)
{
  if (str1 == NULL || str2 == NULL || len == 0)
    return (1);
  while (len > 0)
    {
      if (*(str1++) != *(str2++))
	return (1);
      len--;
    }
  return (0);
}
